home *** CD-ROM | disk | FTP | other *** search
- Path: druid.borland.com!usenet
- From: pete@borland.com (Pete Becker)
- Newsgroups: comp.lang.c
- Subject: Re: void main() and other atrocities!
- Date: 7 Feb 1996 23:46:59 GMT
- Organization: Borland International
- Message-ID: <4fbdlj$o4g@druid.borland.com>
- References: <4eduaj$1aq@grouper.Exis.Net> <4em17r$shq@jaxnet.jaxnet.com> <4emub9$1mo@fountain.mindlink.net> <4epplj$egf@host-3.cyberhighway.net> <4erjn2INN38b@keats.ugrad.cs.ubc.ca> <9602021300.AA04359@dxmint.cern.ch> <4f5vc2$qcj@cdn_news.telecom.com.au>
- NNTP-Posting-Host: pbecker.borland.com
- Mime-Version: 1.0
- Content-Type: Text/Plain; charset=ISO-8859-1
- X-Newsreader: WinVN 0.99.5
-
- In article <4f5vc2$qcj@cdn_news.telecom.com.au>,
- jolson@vprpmel1.telecom.com.au says...
- >
- >How about:
- >
- >int main (int argc, char **argv)
- >
- >I saw in the FAQ that a multi-dimentional array will not decay into a pointer
- >to a pointer. This main() is valid with my Sparcworks compiler so I would
- >like to know if my compiler is supporting non-standard behavior or if argv is
- >a pointer to an array of characters (meaning it can decay into a pointer to a
- >pointer).
-
- In almost all contexts, the name of an array decays into a pointer to the
- first element of the array. The argv parameter is the name of an array of
- pointers to char, not a pointer to an array of characters. Since it is the
- name of an array, it can decay into a pointer, which is why you can treat it
- as a pointer to a pointer. In C syntax:
-
- char *argv[]; /* argv is an array of pointers to char */
- char (*not_argv)[]; /* not_argv is a pointer to an array of char */
-
- char **works_like_argv = argv; /* OK */
- char **doesnt_work_like_argv = not_argv; /* not OK */
-
- Since not_argv is not the name of an array, it does not decay into a pointer,
- and the assignment in the last line is not legal.
- -- Pete
-
-